﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SHDM.Web.Models
{
    public class DicReader : Dictionary<string, object>
    {
        public T Get<T>(string key)
        {
            if (this.Keys.Contains(key))
            {
                return (T)this[key];
            }
            return default(T);
        }

        public int GetInt(string key)
        {
            if (this.Keys.Contains(key))
            {
                return int.Parse(this[key].ToString());
            }
            return 0;
        }

        public decimal GetDecimal(string key)
        {
            if (this.Keys.Contains(key))
            {
                return decimal.Parse(this[key].ToString());
            }
            return 0;
        }

        public string Get(string key)
        {
            if (this.Keys.Contains(key))
            {
                return this[key].ToString();
            }
            return string.Empty;
        }
    }
}